import Vue from 'vue';
import Vuex from 'vuex';
import actions from './actions/Actions.js'

Vue.use(Vuex);


const state = {   //要设置的全局访问的state对象
  open_id: '',
  userInfo: {},
  registerBit: false,
  detailsAddress: undefined,//选择地址暂存区
  extract: undefined,//选择银行卡暂存区
  userAddress: {}   //微信定位的地址信息
  //要设置的初始属性值
};


const getters = {   //实时监听state值的变化(最新状态)
  userInfo(state) {  //方法名随意,主要是来承载变化的userInfo的值
    return state.userInfo
  }
};
const mutations = {
  setOpenId: function (state, data) {
    state.open_id = data;
  },

  setUserInfo: function (state, data) {
    state.userInfo = data;
  },
  //手机弹窗
  registerBit: function (state, data) {
    state.registerBit = data;
  },
  //选择地址暂存区
  setDetailsAddress: function (state, data) {
    state.detailsAddress = data;
  },
  //选择银行卡暂存区
  setExtract: function (state, data) {
    state.extract = data;
  },
  //微信定位的地址信息
  userAddress: function (state, data) {
    state.userAddress = data;
  },
};

const store = new Vuex.Store({
  state,
  actions,
  getters,
  mutations,
});
export default store;
